package com.abner.springcloudprovideruser.Controller;

import com.abner.springcloudprovideruser.Service.UserService;
import com.abner.springcloudprovideruser.dao.UserMapper;
import com.abner.springcloudprovideruser.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Abner.Jiang
 * @Description:
 * @Date: Created on 2019/12/10 10:58
 * @ProjectName: springcloud-provider-user
 */
@RestController
public class UserController {
    private static final Logger log = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserService userService;

    @GetMapping("/get/{id}")
    public User get(@PathVariable String id){
        log.info("start to query User , id : [{}]",id);
        User user = null;
        try {
            user = userService.getUser(id);
            log.info("success to query user ! result is : [{}]",user);
        }catch (Exception e){
            log.error("quey user is error ! id : [{}],exception is : [{}]",id,e);
        }
        return user;
    }

}
